﻿#ifndef CHAOYINAPI_H
#define CHAOYINAPI_H
#include <QtNetwork>
#include <QSettings>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QTimer>
#include <QObject>
#include <QString>
#include <time.h>
#include<QTime>
#include <QJsonObject>
#include <QDebug>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include "http_unit.h"
#include <QVariantMap>
#include <chaoyinheader.h>
class chaoyinAPI:public QObject
{
    Q_OBJECT

public:
        chaoyinAPI();
        void creadTable( enum BegType begtype);
        void telnetGetChaoYinData(enum BegType requistType,int pages,int num); //网络访问超赢数据库
        void telnetGetChaoYinData(BegType requistType);
        struct goodsInfo goods_From_Bar(QString bar);        //通过条形码从本地的数据库获取商品信息
        int commit_order(); //提交订单
        void integralQuery(int member);   //积分查询
        void BalanceQuery(int id,QString password); //储值卡余额查询
        void BalanceCost(int id,float je_xf,QString dh,QString password); //储值卡消费
private:
        QNetworkAccessManager *manager;
        QNetworkRequest request;
        QNetworkReply *reply;
        http_unit unit;
        QSqlQuery sql_query;
        QSqlDatabase goodsData;
        void goodsmesg_json(QByteArray srcdata);//解析json
        void member_xml(QByteArray xmlData); // 解析xml
        void addToSqlite(QJsonObject Goods);
        QByteArray allData;
        int  pages;
        enum BegType begtype;
        void requstMember(QString jsonParam);
        int xh;//储值卡消费是用到的序号
private slots:
      void on_readyRead();
      void goods_mesg();

};

#endif // CHAOYINAPI_H
